package com.hiwan.framework.servlet.tags;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.Tag;
import javax.servlet.jsp.tagext.TagSupport;

import com.hiwan.platform.util.BeanUtils;
import com.hiwan.system.pojo.OrgInfo;
import com.hiwan.system.service.org.OrgService;

/**
 * 
 * Datetime ： 2013-1-29 下午3:27:58<br>
 * Title : DictNameByCodeTag.java<br>
 * Description: 根据字典表的code获取name <br>
 * Copyright : Copyright (c) 2013<br>
 * Company : HIWAN<br>
 * 
 * @author zdm
 * 
 */
public class RootOrgTag extends TagSupport {
	private static final long serialVersionUID = -7389543849788306702L;
	private JspWriter out;
	private boolean showName = false;

	@Override
	public int doStartTag() {
		OrgService orgService = BeanUtils.getBean("orgService",
				OrgService.class);
		out = pageContext.getOut();
		try {
				OrgInfo rootOrg = orgService.getRootOrgInfo();
				if (rootOrg == null) {
					out.print("");
				} else {
					if (showName == true) {
						out.print(rootOrg.getOrgName() + "(" + rootOrg.getOrgId() + ")");
					} else {
						out.print(rootOrg.getOrgId());
					}
				}

		} catch (Exception e) {
		}
		return Tag.EVAL_PAGE;
	}

	public boolean isShowName() {
		return showName;
	}

	public void setShowName(boolean showName) {
		this.showName = showName;
	}



	

}
